<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');


require_once 'CIS_Messages.php';

class CIS_Controller extends Controller 
{
    protected $messages;
    protected $layout;
    protected $pageTitle;
    protected $moduleName;
    
    public function __construct() {
		parent::__construct();
		$this->layout = 'layouts/default';

		$this->pageTitle = 'Default Title';
		$this->moduleName = 'Default Module';
		$this->load->module_model(get_class($this));
		//
		//if (!$this->Model->ismoduleopen())
		//{
		//	$modulename = $this->Model->modulename();
		//	$this->set_closedmodule($modulename);
		//	redirect('module_closed');
		//}
		$this->messages = new CIS_Messages();
    }
    
    protected function clear_layout(){
        $this->layout = null;
    }
    
    protected function set_layout($layout){
        if(isset($layout)){
            $this->layout = 'layouts/' . $layout;
        }
    }
    
    protected function load_view($view, $vars = array(), $return = false) {
            if (is_null($this->layout))
                    return $this->load->view($view, $vars, $return);
            else {
                    $params = array();
                    $params['pageTitle'] = $this->pageTitle;
                    $params['moduleName'] = $this->moduleName;
                    $params['view'] = $view;
                    $params['vars'] = $vars;
                    //this->User_info is an autoload model
                 //   $params['login'] = $this->User_info->current_login();
                    
                    
                    return $this->load->view($this->layout, $params, $return);
            }
    }
    
    
}